
#ifndef __OLED_H
#define __OLED_H

#include "Arduino.h"


#define BLACK 0
#define WHITE 0XFF

#define OLED_Width 128
#define OLED_High  64

// IIC_SDA -> GPIO4
// IIC_SCL -> GPIO15

//-----------------OLED端口定义---------------- 
#define OLED_SCLK_Clr() digitalWrite(15,LOW)
#define OLED_SCLK_Set() digitalWrite(15,HIGH)//SCL

#define OLED_SDIN_Clr() digitalWrite(4,LOW)//DIN
#define OLED_SDIN_Set() digitalWrite(4,HIGH)

#define OLED_RST_Clr() digitalWrite(16,LOW)//RST
#define OLED_RST_Set() digitalWrite(16,HIGH)

#define OLED_CMD  0	//写命令
#define OLED_DATA 1	//写数据
#define x_offset 0  //x轴偏移量

#define CHARGEPUMP 0x8D
#define COLUMNADDR 0x21
#define COMSCANDEC 0xC8
#define COMSCANINC 0xC0
#define DISPLAYALLON 0xA5
#define DISPLAYALLON_RESUME 0xA4
#define DISPLAYOFF 0xAE
#define DISPLAYON 0xAF
#define EXTERNALVCC 0x1
#define INVERTDISPLAY 0xA7
#define MEMORYMODE 0x20
#define NORMALDISPLAY 0xA6
#define PAGEADDR 0x22
#define SEGREMAP 0xA0
#define SETCOMPINS 0xDA
#define SETCONTRAST 0x81
#define SETDISPLAYCLOCKDIV 0xD5
#define SETDISPLAYOFFSET 0xD3
#define SETHIGHCOLUMN 0x10
#define SETLOWCOLUMN 0x00
#define SETMULTIPLEX 0xA8
#define SETPRECHARGE 0xD9
#define SETSEGMENTREMAP 0xA1
#define SETSTARTLINE 0x40
#define SETVCOMDETECT 0xDB
#define SWITCHCAPVCC 0x2

void OLED_ClearPoint(uint8_t x,uint8_t y);
void OLED_ColorTurn(uint8_t i);
void OLED_DisplayTurn(uint8_t i);
void I2C_Start(void);
void I2C_Stop(void);
void I2C_WaitAck(void);
void Send_Byte(uint8_t dat);
void OLED_WR_Byte(uint8_t dat,uint8_t mode);
void OLED_DisPlay_On(void);
void OLED_DisPlay_Off(void);
void OLED_Refresh(void);
void OLED_Clear(void);
void OLED_DrawPoint(uint8_t x,uint8_t y);
void OLED_DrawLine(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2);
void OLED_DrawCircle(uint8_t x,uint8_t y,uint8_t r);
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t size1);
void OLED_ShowString(uint8_t x,uint8_t y,char *chr,uint8_t size1);
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size1);
void OLED_ShowChinese(uint8_t x,uint8_t y,uint8_t num,uint8_t size1);
void OLED_ScrollDisplay(uint8_t num,uint8_t space);
void OLED_WR_BP(uint8_t x,uint8_t y);
void OLED_ShowPicture(uint8_t x,uint8_t y,uint8_t width,uint8_t length,const uint8_t *pic);
void OLED_Init(void);
void OLED_Fill(void);

void OLED_RefreshPage(uint8_t page);
void OLED_ClearPage(uint8_t page,uint8_t color);

void OLED_Debug(char *str,uint8_t line);

void FillByte(int page,int x,unsigned  char byte);
void FillRect(int x,int y,int width,int height);




#endif








